#
# pH+ Container
#

require 'ph/ui/control'

module Ph
  
  class Container < Ph::Control
  
    attr_reader :body
    attr_accessor :template
  
    def initialize(body=false)
      super()
      @tag  = 'div'
      @body = Ph::Collection.new
      @body.add body if body
    end

    # TODO should this method be called like this?
    def generate_body
      if (@template) then @template.generate(@body) else "#@body" end
    end
  
    def to_s
      body = self.generate_body
     
      "<#@tag#@properties>#{body}</#@tag>"
    end

		def [](key)
			@body[key]
		end
  
  end
end
